<?php
	require_once '../lib/upload.class.php';
	require_once '../../lib/sql.utils.php';
	
	$name = $_POST ['name'];
	$address = $_POST ['address'];
	$homePage = $_POST['home'];
	$description = $_POST ['description'];
	$image;
	if (! empty ( $_POST )) {
		$upload = new Upload ( 'upload' );
		$upload->setFileExtension ( 'gif|jpg|png' );
		$upload->setFileSize ( 5000 );
		$upload->setUploadDir ( '../../images/publisher/' );
		if ($upload->isVail () == false) {
			$upload->upload ( true );
		}
		$image = $upload->getFileName ();
	}
	
	$sql_util = new SqlUtils();
	$colList = array('publisherName','publisherAddress','publisherLogo','publisherHomePage','publisherDescription');
	$rowList = array(array('"'.$name.'"','"'.$address.'"','"'.$image.'"','"'.$homePage.'"','"'.$description.'"'));
	$tbl = 'publishers';
	$result = $sql_util->insertRows($colList,$rowList,$tbl);
	//var_dump($sql_util->insertRows($colList,$rowList,$tbl));
	if($result == true) echo 'success';
	else {
		echo 'error';
	}
	header("location:../index.php");
?>